package net.minecraft.src;

import java.util.Map;
import java.util.Random;
import net.minecraft.client.Minecraft;

public class mod_pph extends BaseMod
{

    public mod_pph()
    {
        ModLoader.SetInGameHook(this, true, true);
        ModLoader.SetInGUIHook(this, true, true);
		registerBlocks();
		registerNames();
		registerSprites();
		registerCraftingAndSmelting();
		registerEntities();
		registerTileEntity();
		registerAchievements();
		renderBlockAlgae = ModLoader.getUniqueBlockModelID(this, false);
		renderBlockPlant = ModLoader.getUniqueBlockModelID(this, false);
		timeInPortal = 0;
		mustReturnToCarboniferous = false;
    }
	
	public static void AddTextureFX(TextureFX texturefx)
	{
		System.out.println("Adding TextureFX " + texturefx.getClass().getName());
		ModLoader.getMinecraftInstance().renderEngine.registerTextureFX(texturefx);
	}

	public static void SpawnParticle(EntityFX particle)
	{
		ModLoader.getMinecraftInstance().effectRenderer.addEffect(particle);
	}
	
	public boolean OnTickInGame(float f, Minecraft minecraft)
    {
		if(minecraft.thePlayer != null && isInPortal(minecraft))
		{
			timeInPortal++;
			if(timeInPortal == 40 && minecraft.thePlayer.dimension == 0)
			{
				teleportToCarboniferous(minecraft);
				timeInPortal = 0;
			} else
			if(timeInPortal == 40 && minecraft.thePlayer.dimension == 5)
			{
				teleportToOverworld(minecraft);
				timeInPortal = 0;
			}
		}
		if(minecraft.thePlayer != null && minecraft.thePlayer.dimension == 5 && !(minecraft.theWorld.worldProvider instanceof WorldProviderPrePrehistoric))
        {
            returnToCarboniferous(minecraft);
        }
		if(mustReturnToCarboniferous == true)
		{
			if(minecraft.thePlayer != null)
			{
				returnToCarboniferous(minecraft);
				mustReturnToCarboniferous = false;
			}
		}
		if(minecraft.thePlayer != null && minecraft.thePlayer.dimension != 5 && (minecraft.theWorld instanceof WorldPPH))
        {
            returnToCarboniferous(minecraft);
        }
		if(minecraft.thePlayer != null && minecraft.thePlayer.dimension != 5 && (minecraft.theWorld.worldProvider instanceof WorldProviderPrePrehistoric))
        {
			returnToCarboniferous(minecraft);
        }
		if(minecraft.thePlayer != null && minecraft.thePlayer.inPortal && minecraft.thePlayer.dimension == 5)
		{
		for(int i = -2; i < 2; i++)
		{
			for(int j = -2; j < 2; j++)
			{
				for(int k = -2; k < 2; k++)
				{
					if(minecraft.theWorld.getBlockId((int)minecraft.thePlayer.posX + i, (int)minecraft.thePlayer.posY + j, (int)minecraft.thePlayer.posZ + k) == Block.portal.blockID)
					{
						minecraft.theWorld.setBlock((int)minecraft.thePlayer.posX + i, (int)minecraft.thePlayer.posY + j, (int)minecraft.thePlayer.posZ + k, 0);
					}
				}
			}
		}
		}
		return true;
	}
	
	public boolean OnTickInGUI(float f, Minecraft minecraft, GuiScreen guiscreen)
    {
        OnTickInGame(f, minecraft);
		return true;
    }
	
	public static boolean mustReturnToCarboniferous;
	
	public boolean isInPortal(Minecraft minecraft)
    {
		int x = (int) Math.floor(minecraft.thePlayer.posX);
		int y = (int) Math.floor(minecraft.thePlayer.posY);
		int z = (int) Math.floor(minecraft.thePlayer.posZ);
		return (minecraft.thePlayer.worldObj.getBlockId(x, y, z) == portalBlock.blockID && minecraft.thePlayer.worldObj.getBlockId(x, y - 1, z) == portalBlock.blockID) ? true : false;
    }
	
	public void teleportToCarboniferous(Minecraft minecraft)
    {
        minecraft.theWorld.setEntityDead(minecraft.thePlayer);
        minecraft.thePlayer.isDead = false;
            minecraft.thePlayer.setLocationAndAngles(minecraft.thePlayer.posX, minecraft.thePlayer.posY, minecraft.thePlayer.posZ, minecraft.thePlayer.rotationYaw, minecraft.thePlayer.rotationPitch);
            if(minecraft.thePlayer.isEntityAlive())
            {
                minecraft.theWorld.updateEntityWithOptionalForce(minecraft.thePlayer, false);
            }
            WorldPPH world = null;
            world = new WorldPPH(minecraft.theWorld, new WorldProviderPrePrehistoric());
            minecraft.changeWorld(world, "Entering the Carboniferous", minecraft.thePlayer);
			minecraft.thePlayer.dimension = 5;
		minecraft.thePlayer.worldObj = minecraft.theWorld;
        if(minecraft.thePlayer.isEntityAlive())
        {
            minecraft.thePlayer.setLocationAndAngles(minecraft.thePlayer.posX, minecraft.thePlayer.posY, minecraft.thePlayer.posZ, minecraft.thePlayer.rotationYaw, minecraft.thePlayer.rotationPitch);
            minecraft.theWorld.updateEntityWithOptionalForce(minecraft.thePlayer, false);
            (new TeleporterPrePrehistoric()).placeInPortal(minecraft.theWorld, minecraft.thePlayer);
			minecraft.thePlayer.addStat(enterdimension, 1);
        }             
	}
	
	public void teleportToOverworld(Minecraft minecraft)
    {
        minecraft.theWorld.setEntityDead(minecraft.thePlayer);
        minecraft.thePlayer.isDead = false;
            minecraft.thePlayer.setLocationAndAngles(minecraft.thePlayer.posX, minecraft.thePlayer.posY, minecraft.thePlayer.posZ, minecraft.thePlayer.rotationYaw, minecraft.thePlayer.rotationPitch);
            if(minecraft.thePlayer.isEntityAlive())
            {
                minecraft.theWorld.updateEntityWithOptionalForce(minecraft.thePlayer, false);
            }
            World world = null;
            world = new World(minecraft.theWorld, WorldProvider.getProviderForDimension(0));
            minecraft.changeWorld(world, "Leaving the Carboniferous", minecraft.thePlayer);
			minecraft.thePlayer.dimension = 0;
		minecraft.thePlayer.worldObj = minecraft.theWorld;
        if(minecraft.thePlayer.isEntityAlive())
        {
            minecraft.thePlayer.setLocationAndAngles(minecraft.thePlayer.posX, minecraft.thePlayer.posY, minecraft.thePlayer.posZ, minecraft.thePlayer.rotationYaw, minecraft.thePlayer.rotationPitch);
            minecraft.theWorld.updateEntityWithOptionalForce(minecraft.thePlayer, false);
            (new TeleporterPrePrehistoric()).placeInPortal(minecraft.theWorld, minecraft.thePlayer);
        }
	}
	
	public static void returnToCarboniferous(Minecraft minecraft)
    {
        minecraft.theWorld.setEntityDead(minecraft.thePlayer);
        minecraft.thePlayer.isDead = false;
        minecraft.thePlayer.setLocationAndAngles(minecraft.thePlayer.posX, minecraft.thePlayer.posY, minecraft.thePlayer.posZ, minecraft.thePlayer.rotationYaw, minecraft.thePlayer.rotationPitch);
        if(minecraft.thePlayer.isEntityAlive())
        {
            minecraft.theWorld.updateEntityWithOptionalForce(minecraft.thePlayer, false);
        }
        WorldPPH world = null;
        world = new WorldPPH(minecraft.theWorld, new WorldProviderPrePrehistoric());
        minecraft.changeWorld(world, "Entering the Carboniferous", minecraft.thePlayer);
        minecraft.thePlayer.worldObj = minecraft.theWorld;
        minecraft.thePlayer.dimension = 5;
    }
	
	public static void returnToOverworld(Minecraft minecraft, int i)
    {
        minecraft.theWorld.setEntityDead(minecraft.thePlayer);
        minecraft.thePlayer.isDead = false;
        minecraft.thePlayer.setLocationAndAngles(minecraft.thePlayer.posX, minecraft.thePlayer.posY, minecraft.thePlayer.posZ, minecraft.thePlayer.rotationYaw, minecraft.thePlayer.rotationPitch);
        if(minecraft.thePlayer.isEntityAlive())
        {
            minecraft.theWorld.updateEntityWithOptionalForce(minecraft.thePlayer, false);
        }
        World world = null;
        world = new World(minecraft.theWorld, WorldProvider.getProviderForDimension(0));
		if(i == 1)
		{
			minecraft.changeWorld(world, "Thanks for testing the Pre-Prehistoric Mod!", minecraft.thePlayer);
		} else
		{
			minecraft.changeWorld(world, "Leaving the Carboniferous", minecraft.thePlayer);
		}
        minecraft.thePlayer.worldObj = minecraft.theWorld;
        minecraft.thePlayer.dimension = 0;
		if(i == 1)
		{
			BlockTimeBox.formPortal(world, (int)minecraft.thePlayer.posX, (int)minecraft.thePlayer.posY - 1, (int)minecraft.thePlayer.posZ, 44, 109, 98, mod_pph.portalBlock.blockID);
			minecraft.theWorld.setBlockAndMetadataWithNotify((int)minecraft.thePlayer.posX, (int)minecraft.thePlayer.posY - 2, (int)minecraft.thePlayer.posZ, timeBox.blockID, 1);
		}
    }
	
	private void registerEntities()
	{
		ModLoader.RegisterEntityID(EntityAmmonite.class, "Ammonite", ModLoader.getUniqueEntityId());
		ModLoader.RegisterEntityID(EntityBrachiopod.class, "Brachiopod", ModLoader.getUniqueEntityId());
		ModLoader.RegisterEntityID(EntityDragonfly.class, "Dragonfly", ModLoader.getUniqueEntityId());
		ModLoader.RegisterEntityID(EntityMesothelae.class, "Mesothelae", ModLoader.getUniqueEntityId());
		ModLoader.RegisterEntityID(EntitySwampMonster.class, "SwampMonster", ModLoader.getUniqueEntityId());
		ModLoader.RegisterEntityID(EntityTrilobite.class, "Trilobite", ModLoader.getUniqueEntityId());
	}
	
	public void AddRenderer(Map map)
	{
		map.put(EntityAmmonite.class, new RenderAmmonite(0.0F));
		map.put(EntityBrachiopod.class, new RenderBrachiopod(new ModelBrachiopod(), 0.0F));
		map.put(EntityDragonfly.class, new RenderDragonfly(new ModelDragonfly(), 0.5F));
		map.put(EntityMesothelae.class, new RenderMesothelae(0.0F));
		map.put(EntitySwampMonster.class, new RenderSwampMonster(0.0F));
		map.put(EntityTrilobite.class, new RenderTrilobite(0.0F));
	}

	private void registerBlocks()
	{
		ModLoader.RegisterBlock(timeBox);
		ModLoader.RegisterBlock(portalBlock);
		ModLoader.RegisterBlock(algae, net.minecraft.src.ItemBlockAlgae.class);
		ModLoader.RegisterBlock(prehistoricSpawner);
		ModLoader.RegisterTileEntity(net.minecraft.src.TileEntityPrehistoricSpawner.class, "PrehistoricSpawner");
		ModLoader.RegisterBlock(prehistoricDirt);
		ModLoader.RegisterBlock(prehistoricWood, net.minecraft.src.ItemBlockPrehistoricWood.class);
		ModLoader.RegisterBlock(prehistoricLeaves, net.minecraft.src.ItemBlockPrehistoricLeaves.class);
		ModLoader.RegisterBlock(prehistoricLimestone); 
		ModLoader.RegisterBlock(prehistoricGrass);
		ModLoader.RegisterBlock(prehistoricPlant, net.minecraft.src.ItemBlockPrehistoricPlant.class);
		ModLoader.RegisterBlock(grassTrap); 
		ModLoader.RegisterBlock(prehistoricVine);
		ModLoader.RegisterBlock(prehistoricSapling, net.minecraft.src.ItemBlockPrehistoricSapling.class);
		ModLoader.RegisterBlock(pyriteOre);
		ModLoader.RegisterBlock(charcarbon);
		ModLoader.RegisterBlock(blockGrinder);
	}
	
	private void registerNames()
	{
		ModLoader.AddName(timeRod, "Time Rod");
		ModLoader.AddName(net, "Net");
		ModLoader.AddName(algaeItem, "Algae");
		ModLoader.AddName(ammoniteShell, "Ammonite Shell");
		ModLoader.AddName(brachiopodShell, "Brachiopod Shell");
		ModLoader.AddName(shellPowder, "Shell Powder");
		ModLoader.AddName(charcarbonItem, "Charcarbon");
		ModLoader.AddName(fang, "Fang");
		ModLoader.AddName(fangDagger, "Fang Dagger");
		ModLoader.AddName(dragonflyEggs, "Dragonfly Eggs");
		ModLoader.AddName(dragonflyItem, "Dragonfly");
		ModLoader.AddName(dragonflyCooked, "Cooked Dragonfly");
		ModLoader.AddName(dragonflyWing, "Dragonfly Wing");
		ModLoader.AddName(dragonflyEggsCooked, "Cooked Dragonfly Eggs");
		ModLoader.AddName(ironNugget, "Iron Nugget");
		ModLoader.AddName(amphibianMeat, "Amphibian Meat");
		ModLoader.AddName(amphibianMeatCooked, "Cooked Amphibian Meat");
		ModLoader.AddName(timeBox, "Time Box");
		ModLoader.AddName(portalBlock, "Prehistoric Portal");
		ModLoader.AddName(new ItemStack(algae, 1, 0), "Algae");
		ModLoader.AddName(new ItemStack(algae, 1, 1), "Algae");
		ModLoader.AddName(new ItemStack(algae, 1, 2), "Dragonfly Eggs");
		ModLoader.AddName(new ItemStack(algae, 1, 3), "Gloop");
		ModLoader.AddName(prehistoricSpawner, "Carboniferous Monster Spawner");
		ModLoader.AddName(prehistoricDirt, "Carboniferous Soil");
		ModLoader.AddName(new ItemStack(prehistoricWood, 1, 0), "Carboniferous Log");
		ModLoader.AddName(new ItemStack(prehistoricWood, 1, 1), "Carboniferous Log");
		ModLoader.AddName(new ItemStack(prehistoricWood, 1, 2), "Carboniferous Log");
		ModLoader.AddName(new ItemStack(prehistoricWood, 1, 3), "Carboniferous Log");
		ModLoader.AddName(new ItemStack(prehistoricLeaves, 1, 0), "Carboniferous Leaves");
		ModLoader.AddName(new ItemStack(prehistoricLeaves, 1, 1), "Carboniferous Leaves");
		ModLoader.AddName(new ItemStack(prehistoricLeaves, 1, 2), "Carboniferous Leaves");
		ModLoader.AddName(prehistoricLimestone, "Carboniferous Limestone");
		ModLoader.AddName(prehistoricGrass, "Carboniferous Grass");
		ModLoader.AddName(new ItemStack(prehistoricPlant, 1, 0), "Dead Shrub");
		ModLoader.AddName(new ItemStack(prehistoricPlant, 1, 1), "Tall Grass");
		ModLoader.AddName(new ItemStack(prehistoricPlant, 1, 2), "Fern");
		ModLoader.AddName(new ItemStack(prehistoricSapling, 1, 0), "Lepidodendron Sapling");
		ModLoader.AddName(new ItemStack(prehistoricSapling, 1, 1), "Calamites Sapling");
		ModLoader.AddName(new ItemStack(prehistoricSapling, 1, 2), "Cordaites Sapling");
		ModLoader.AddName(grassTrap, "Grass Trap");
		ModLoader.AddName(prehistoricVine, "Carboniferous Vine");
		ModLoader.AddName(pyriteOre, "Pyrite Ore");
		ModLoader.AddName(charcarbon, "Charcarbon");
		ModLoader.AddName(blockGrinder, "Grinder");
	}
	
	private void registerSprites()
	{
		timeRod.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/timerod.png");
		net.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/net.png");
		algaeItem.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/algaeItem.png");
		ammoniteShell.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/ammoniteShell.png");
		brachiopodShell.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/brachiopodShell.png");
		shellPowder.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/shellPowder.png");
		fang.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/fang.png");
		fangDagger.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/fangDagger.png");
		dragonflyEggs.iconIndex = dragonflyEggsCooked.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/eggs.png");
		dragonflyItem.iconIndex = dragonflyCooked.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/dragonflyItem.png");
		dragonflyWing.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/wing.png");
		ironNugget.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/ironNugget.png");
		amphibianMeat.iconIndex = amphibianMeatCooked.iconIndex = ModLoader.addOverride("/gui/items.png", "/pph/amphibianMeat.png");
		timeBox.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/timebox0.png");
		portalBlock.blockIndexInTexture = ModLoader.getUniqueSpriteIndex("/terrain.png");
		AddTextureFX(new TexturePPHPortalFX());
		algae.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/algae.png");
		prehistoricSpawner.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/spawner.png");
		prehistoricDirt.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/dirt.png");
		prehistoricWood.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/wood.png");
		prehistoricLimestone.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/limestone.png");
		prehistoricGrass.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/grassside.png");
		grassTrap.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/grasstop.png");
		prehistoricVine.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/vine.png");
		prehistoricSapling.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/lepidodendronSapling.png");
		pyriteOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/pyrite.png");
		charcarbon.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/charcarbon.png");
		blockGrinder.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/pph/grinder_s.png");
		((BlockGrinder) blockGrinder).blockIndexInTextureFront = ModLoader.addOverride("/terrain.png", "/pph/grinder_f.png");
	}
	
	private void registerCraftingAndSmelting()
	{
		ModLoader.AddRecipe(new ItemStack(timeRod, 1), new Object[] { "  d", " s ", "s  ", Character.valueOf('d'), Item.diamond, Character.valueOf('s'), Item.stick });
		ModLoader.AddRecipe(new ItemStack(timeBox, 1), new Object[] { "gig", "drd", "gig", Character.valueOf('g'), Item.lightStoneDust, Character.valueOf('i'), Item.ingotIron, Character.valueOf('d'), Item.diamond, Character.valueOf('r'), Block.torchRedstoneActive });
		ModLoader.AddRecipe(new ItemStack(Block.planks, 4), new Object[] { "x", Character.valueOf('x'), prehistoricWood });
		ModLoader.AddRecipe(new ItemStack(net, 1), new Object[] { " xx", " sx", " s ", Character.valueOf('x'), Item.silk, Character.valueOf('s'), Item.stick });
		ModLoader.AddRecipe(new ItemStack(fangDagger, 1), new Object[] { "X", "|", Character.valueOf('X'), fang, Character.valueOf('|'), Item.stick }); 
		ModLoader.AddRecipe(new ItemStack(Item.arrow, 4), new Object[] { "f", "s", "w", Character.valueOf('f'), Item.flint, Character.valueOf('s'), Item.stick, Character.valueOf('w'), dragonflyWing });
		ModLoader.AddRecipe(new ItemStack(Item.ingotIron, 1), new Object[] { "iii", "iii", "iii", Character.valueOf('i'), ironNugget });
		ModLoader.AddRecipe(new ItemStack(blockGrinder, 1), new Object[] { "ccc", "s s", "csc",Character.valueOf('c'), Block.cobblestone,Character.valueOf('s'), Block.stone });
		
		ModLoader.AddSmelting(dragonflyItem.shiftedIndex, new ItemStack(dragonflyCooked));
		ModLoader.AddSmelting(dragonflyEggs.shiftedIndex, new ItemStack(dragonflyEggsCooked));
		ModLoader.AddSmelting(pyriteOre.blockID, new ItemStack(ironNugget));
		ModLoader.AddSmelting(amphibianMeat.shiftedIndex, new ItemStack(amphibianMeatCooked));
	}
	
	private void registerTileEntity()
	{
		ModLoader.RegisterTileEntity(TileEntityGrinder.class, "GrinderTile");
	}
	
	public int AddFuel(int i, int j)
	{
		if(i == charcarbonItem.shiftedIndex)
        {
            return 2400;
        } else
		{
			return -1;
		}
	}
	
    public static final Block timeBox;
	public static final Block portalBlock;
	public static final	Block algae;
	public static final Block prehistoricSpawner;
	public static final Block prehistoricDirt;
	public static final Block prehistoricWood;
	public static final Block prehistoricLimestone;
	public static final Block prehistoricGrass;
	public static final Block prehistoricLeaves;
	public static final	Block prehistoricPlant;
	public static final Block grassTrap;
	public static final Block prehistoricVine;
	public static final Block prehistoricSapling;
	public static final Block pyriteOre;
	public static final Block charcarbon;
	public static final Block blockGrinder;
	public static final Item timeRod = new ItemTimeRod(15000).setItemName("Time Rod");
	public static final Item net = new ItemNet(15001).setItemName("Net");
	public static final Item algaeItem = new ItemAlgae(15002, 0).setItemName("Algae");
	public static final Item ammoniteShell = new Item(15003).setItemName("Ammonite Shell");
	public static final Item brachiopodShell = new Item(15004).setItemName("Brachiopod Shell");
	public static final Item shellPowder = new ItemShellPowder(15005).setItemName("Shell Powder");
	public static final Item fang = new Item(15006).setItemName("Fang");
	public static final Item fangDagger = new ItemPrehistoricDagger(15007, EnumToolMaterialPPH.BONE).setItemName("Fang Dagger");
	public static final Item charcarbonItem = new ItemCharcarbon(15008).setIconCoord(7, 0).setItemName("Charcarbon");
	public static final Item dragonflyEggs = new ItemAlgae(15009, 2).setItemName("Dragonfly Eggs");
	public static final Item dragonflyItem = new ItemDragonfly(15010).setItemName("Dragonfly");
	public static final Item dragonflyCooked = new ItemDragonflyCooked(15011, 6, 0.6F, false).setItemName("Cooked Dragonfly");
	public static final Item dragonflyWing = new Item(15012).setItemName("Dragonfly Wing");
	public static final Item dragonflyEggsCooked = new ItemDragonflyCooked(15013, 3, 0.3F, false).setItemName("Cooked Dragonfly Eggs");
	public static final Item ironNugget = new Item(15014).setItemName("Iron Nugget");
	public static final Item amphibianMeat = new ItemFood(15015, 3, 0.3F, true).setItemName("Amphibian Meat");
	public static final Item amphibianMeatCooked = new ItemAmphibianMeatCooked(15016, 8, 0.8F, true).setItemName("Cooked Amphibian Meat");
	
	static
	{
	portalBlock = new BlockPrehistoricPortal(151, 30).setHardness(-1F).setStepSound(Block.soundGlassFootstep).setLightValue(0.75F).setBlockName("Carboniferous Portal");
	timeBox = new BlockTimeBox(152, 0).setHardness(2.0F).setResistance(5.0F).setBlockName("Time Turner");
	algae = new BlockAlgae(153).setHardness(-1F).setBlockName("Algae").setRequiresSelfNotify();
	prehistoricSpawner = new BlockPrehistoricSpawner(154, 0).setHardness(2.0F).setResistance(5F).setStepSound(Block.soundStoneFootstep).setBlockName("Prehistoric Spawner");  
	prehistoricWood = new BlockPrehistoricWood(155, 0).setHardness(1.0F).setResistance(2F).setStepSound(Block.soundWoodFootstep).setBlockName("Prehistoric Wood");
	prehistoricLimestone = new BlockPrehistoricLimestone(156, 0).setHardness(1.0F).setResistance(7.5F).setStepSound(Block.soundStoneFootstep).setBlockName("Prehistoric Limestone");  
	prehistoricDirt = new BlockPrehistoricDirt(157, 0).setHardness(0.6F).setStepSound(Block.soundGravelFootstep).setBlockName("Prehistoric Dirt"); 
	prehistoricGrass = new BlockPrehistoricGrass(158, 0).setHardness(0.8F).setStepSound(Block.soundGrassFootstep).setBlockName("Prehistoric Grass"); 
	prehistoricLeaves = new BlockPrehistoricLeaves(159, 52).setHardness(0.2F).setLightOpacity(1).setStepSound(Block.soundGrassFootstep).setBlockName("Prehistoric Leaves").setRequiresSelfNotify();
	prehistoricPlant = new BlockPrehistoricPlant(160, 0).setHardness(0.0F).setStepSound(Block.soundGrassFootstep).setBlockName("Prehistoric Plant");
	grassTrap = new BlockGrassTrap(161, 0).setHardness(0.2F).setStepSound(Block.soundGrassFootstep).setBlockName("Grass Trap"); 
	prehistoricVine = (new BlockPrehistoricVine(162, 0)).setHardness(0.2F).setBlockName("Prehistoric Vine").setRequiresSelfNotify();
	prehistoricSapling = (new BlockPrehistoricSapling(163, 0)).setHardness(0.0F).setStepSound(Block.soundGrassFootstep).setBlockName("Prehistoric Sapling").setRequiresSelfNotify();
	pyriteOre = new BlockPyriteOre(164, 0).setHardness(3F).setResistance(4.0F).setBlockName("Pyrite Ore");
	charcarbon = new BlockCharcarbon(165, 0).setHardness(2F).setResistance(1.0F).setBlockName("Charcarbon");
	blockGrinder = new BlockGrinder(166, 0).setHardness(2.0F).setResistance(5.0F).setBlockName("Grinder");
	}
	
	public boolean RenderWorldBlock(RenderBlocks renderblocks, IBlockAccess iblockaccess, int i, int j, int k, Block block, int l)
	{
		if(l == renderBlockAlgae)
		{
			return renderBlockAlgae(renderblocks, iblockaccess, i, j, k, block, l); 
		}
		if(l == renderBlockPlant)
		{
			return renderBlockPlant(renderblocks, iblockaccess, i, j, k, block, l); 
		}
		return false;
	}
	
	public boolean renderBlockAlgae(RenderBlocks renderblocks, IBlockAccess iblockaccess, int i, int j, int k, Block block, int l)
	{
		Tessellator tessellator = Tessellator.instance;
		tessellator.setBrightness(block.getMixedBrightnessForBlock(iblockaccess, i, j, k));
		int l1 = iblockaccess.getBlockMetadata(i, j, k);
        int i1 = block.getBlockTextureFromSideAndMetadata(0, l1);
        float f = block.getBlockBrightness(iblockaccess, i, j, k);
        tessellator.setColorOpaque_F(f, f, f);
      
        int j1 = (i1 & 0xf) << 4;
        int k1 = i1 & 0xf0;

        double tax = ((float)j1 + 16F) / 256F;
        double tay = (float)k1 / 256F;
        double tbx = (float)j1 / 256F;
        double tby = ((float)k1 + 16F) / 256F;
		
		tessellator.addVertexWithUV(i + 1, j - .1, k, tax, tay);
        tessellator.addVertexWithUV(i + 1, j - .1, k + 1, tax, tby);
        tessellator.addVertexWithUV(i, j - .1, k + 1, tbx, tby);
        tessellator.addVertexWithUV(i, j - .1, k, tbx, tay);
        tessellator.addVertexWithUV(i, j - .1, k, tbx, tay);
        tessellator.addVertexWithUV(i, j - .1, k + 1, tbx, tby);
        tessellator.addVertexWithUV(i + 1, j - .1, k + 1, tax, tby);
        tessellator.addVertexWithUV(i + 1, j - .1, k, tax, tay);
		return true;
	}
	
	public boolean renderBlockPlant(RenderBlocks renderblocks, IBlockAccess iblockaccess, int i, int j, int k, Block block, int l)
    {
        Tessellator tessellator = Tessellator.instance;
        tessellator.setBrightness(block.getMixedBrightnessForBlock(iblockaccess, i, j, k));
        float f = 1.0F;
        int i1 = block.colorMultiplier(iblockaccess, i, j, k);
        float f1 = (float)(i1 >> 16 & 0xff) / 255F;
        float f2 = (float)(i1 >> 8 & 0xff) / 255F;
        float f3 = (float)(i1 & 0xff) / 255F;
        if(EntityRenderer.anaglyphEnable)
        {
            float f4 = (f1 * 30F + f2 * 59F + f3 * 11F) / 100F;
            float f5 = (f1 * 30F + f2 * 70F) / 100F;
            float f6 = (f1 * 30F + f3 * 70F) / 100F;
            f1 = f4;
            f2 = f5;
            f3 = f6;
        }
        tessellator.setColorOpaque_F(f * f1, f * f2, f * f3);
        double d = i;
        double d1 = j;
        double d2 = k;
        if(block == prehistoricPlant)
        {
            long l1 = (long)(i * 0x2fc20f) ^ (long)k * 0x6ebfff5L ^ (long)j;
            l1 = l1 * l1 * 0x285b825L + l1 * 11L;
            d += ((double)((float)(l1 >> 16 & 15L) / 15F) - 0.5D) * 0.5D;
            d1 += ((double)((float)(l1 >> 20 & 15L) / 15F) - 1.0D) * 0.20000000000000001D;
            d2 += ((double)((float)(l1 >> 24 & 15L) / 15F) - 0.5D) * 0.5D;
        }
        renderblocks.renderCrossedSquares(block, iblockaccess.getBlockMetadata(i, j, k), d, d1, d2);
        return true;
    }
	
	public void TakenFromFurnace(EntityPlayer entityplayer, ItemStack itemstack)
    {
        if(itemstack.itemID == dragonflyEggsCooked.shiftedIndex)
        {
            entityplayer.addStat(youmurderer, 1);
        }
    }

	private void registerAchievements()
	{
		ModLoader.AddAchievementDesc(youmurderer, "You murderer!", "Cook some dragonfly eggs.");
		ModLoader.AddAchievementDesc(enterdimension, "Before the dinosaurs!", "Travel to the Carboniferous.");
		ModLoader.AddAchievementDesc(spiderburrow, "Spiders' Lair", "Find a spider burrow.");
	}
	
	public static Achievement youmurderer = new Achievement(3450, "youmurderer", 10, 2, dragonflyEggsCooked, null).registerAchievement();
	public static Achievement enterdimension = new Achievement(3451, "enterdimension", 10, 1, timeBox, null).registerAchievement();
	public static Achievement spiderburrow = new Achievement(3452, "enterdimension", 11, 1, Block.web, null).registerAchievement();
	
	public String getVersion()
    {
        return "PPH Beta for MC1.0.0";
    }
	
	public void load()
	{
	}

	public static int renderBlockAlgae;
	public static int renderBlockPlant;
	private int timeInPortal;
}